package com.rongc.client.freight.base.view.activity;

import com.rongc.client.freight.R;
import com.rongc.client.freight.base.BaseActivity;

/**
 * Created by Bruce on 2017/7/6.
 */
@Deprecated
public class MapActivity extends BaseActivity {
    /*@Bind(R.id.bmapView)
    MapView mMapView;
    @Bind(R.id.et_search)
    EditText mEtSearch;
    private BaiduMap mBaiduMap;
    PoiSearch mPoiSearch;

    ReverseGeoCodeResult result;

    //构建Marker图标
    BitmapDescriptor bitmap = BitmapDescriptorFactory
            .fromResource(R.mipmap.icon_gcoding);

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        MenuInflater inflater = getMenuInflater();
        inflater.inflate(R.menu.map_menu, menu);
        return super.onCreateOptionsMenu(menu);
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
            case R.id.action_define:
                try{
                    prepare();
                    Intent intent = new Intent();
                    intent.putExtra("data",result);
                    setResult(RESULT_OK,intent);
                    finish();
                }catch (RegexException e){
                    ActivityUtils.toast(e.getMessage());
                }


                return true;
        }
        return super.onOptionsItemSelected(item);
    }

    void prepare() throws RegexException {
        if(!RegexUtil.checkNotNull(result)){
            throw new RegexException("请选择有效地址");
        }
    }


    @Override
    public void initView() {
        initToolbar("选择地址");

        mBaiduMap = mMapView.getMap();
        mPoiSearch = PoiSearch.newInstance();

        OnGetPoiSearchResultListener poiListener = new OnGetPoiSearchResultListener(){
            public void onGetPoiResult(PoiResult result){
                //获取POI检索结果
//                result.getAllPoi().get(0).address;


//                MapStatusUpdate u = MapStatusUpdateFactory.newLatLngZoom(result.get,17.0f);
//                mBaiduMap.animateMapStatus(u);
            }
            public void onGetPoiDetailResult(PoiDetailResult result){
                //获取Place详情页检索结果
            }

            @Override
            public void onGetPoiIndoorResult(PoiIndoorResult poiIndoorResult) {

            }
        };

        mPoiSearch.setOnGetPoiSearchResultListener(poiListener);




        mBaiduMap.setOnMapClickListener(new BaiduMap.OnMapClickListener() {
            public void onMapClick(LatLng point) {
                mBaiduMap.clear();

                //构建MarkerOption，用于在地图上添加Marker
                OverlayOptions option = new MarkerOptions()
                        .position(point)
                        .icon(bitmap);
                //在地图上添加Marker，并显示
                mBaiduMap.addOverlay(option);
                //在此处理点击事件

                MapStatusUpdate u = MapStatusUpdateFactory.newLatLng(point);
                mBaiduMap.animateMapStatus(u);
            }
            public boolean onMapPoiClick(MapPoi poi) {
                //在此处理底图标注点击事件
                return false;
            }
        });

        mBaiduMap.setOnMapStatusChangeListener(new BaiduMap.OnMapStatusChangeListener() {
            @Override
            public void onMapStatusChangeStart(MapStatus mapStatus) {

            }

            @Override
            public void onMapStatusChange(MapStatus mapStatus) {

            }

            @Override
            public void onMapStatusChangeFinish(MapStatus mapStatus) {
                GeoCoder geoCoder = GeoCoder.newInstance();
                geoCoder.reverseGeoCode(new ReverseGeoCodeOption().location(mapStatus.target));
                geoCoder.setOnGetGeoCodeResultListener(new OnGetGeoCoderResultListener() {
                    @Override
                    public void onGetGeoCodeResult(GeoCodeResult geoCodeResult) {

                    }

                    @Override
                    public void onGetReverseGeoCodeResult(ReverseGeoCodeResult reverseGeoCodeResult) {
                        String address = reverseGeoCodeResult.getAddress();
                        if(StringUtils.isNotEmpty(address)){
                            mEtSearch.setText(address);
                            result = reverseGeoCodeResult;
//                            ActivityUtils.toast(address);
                        }
                    }
                });
            }
        });
    }

    @Override
    public void initData() {

    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        //在activity执行onDestroy时执行mMapView.onDestroy()，实现地图生命周期管理
        mMapView.setMapCustomEnable(false);
        mMapView.onDestroy();
        bitmap.recycle();
    }
    @Override
    protected void onResume() {
        //在activity执行onResume时执行mMapView. onResume ()，实现地图生命周期管理
        super.onResume();
        mMapView.onResume();
    }
    @Override
    protected void onPause() {
        //在activity执行onPause时执行mMapView. onPause ()，实现地图生命周期管理
        super.onPause();
        mMapView.onPause();
    }*/

    @Override
    public int getLayoutId() {
        return R.layout.universal_map;
    }
}
